package com.hyq.learn.rabbitmq.constant;

import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.lang.Nullable;

/**
 * @author heyuqin
 * @date 2024/8/21 16:46
 */
public enum DeadLetterQueue {

    /**
     * 死信队列测试
     */
    DEAD_LETTER_QUEUE_1(QueueConstants.DEAD_LETTER_QUEUE, 10_000, null, new FanoutExchange(ExchangeConstants.DEAD_LETTER_EXCHANGE));

    /**
     * 队列名称 (死信队列, 自动创建该队列)
     */
    private final String queueName;

    /**
     * ttl 消息在死信队列的过期时间
     */
    private final Integer ttl;

    /**
     * 路由key，到期后的转发 配合exchange使用
     */
    @Nullable
    private final String routingKey;

    /**
     * 交换机 (自动创建)，到期后的转发
     */
    private final Exchange exchange;

    DeadLetterQueue(String queueName, Integer ttl, @Nullable String routingKey, Exchange exchange) {
        this.queueName = queueName;
        this.ttl = ttl;
        this.routingKey = routingKey;
        this.exchange = exchange;
    }

    public String getQueueName() {
        return queueName;
    }

    public Integer getTtl() {
        return ttl;
    }

    @Nullable
    public String getRoutingKey() {
        return routingKey;
    }

    public Exchange getExchange() {
        return exchange;
    }
}
